package com.demo.bigdata

import org.apache.spark.{SparkConf, SparkContext}

object MapDemo {
  def main(args: Array[String]): Unit = {
    val conf = (new SparkConf).setMaster("local").setAppName("Demo");
    val sc = new SparkContext(conf)
    val lines = sc.parallelize(List("hadoop","hive","spark","hive","sqoop"))
    val res = lines.map { x => "[" + x + "]" }
    res.foreach(println(_))

    val map = lines.map( x => (x,1) )
    val keys = map.keys
    keys.foreach(println(_))
    val values = map.values
    values.foreach(println(_))
    val mapValues = map.mapValues(_+1)
    mapValues.foreach(println(_))
  }
}
